//
//  MyJobListViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/11/16.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "MyJobListViewController.h"
#import "DateSelectView.h"
#import "MyJobListTableViewCell.h"
#import "MyJobListModel.h"
#import "TaskDetailViewController.h"

#define getDutyFlowList @"getDutyFlowList"//任务列表
#define postDeleteBiz @"postDeleteBiz"//撤销公出申请、加班申请、异常解释

@interface MyJobListViewController ()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource>
{
    NSMutableArray *_buttonArr;//保存button
    UITableView *_tableView;//列表
}
@property (nonatomic,strong)MyJobListModel *jobListModel;
@property (nonatomic,strong)UITextField *searchTextField;
@property (nonatomic,strong)UIScrollView *selectScrollView;//筛选view
@property (nonatomic,strong)UIView *statsView;//状态view
@property (nonatomic,strong)UIView *dutyView;//职责view
@property (nonatomic,strong)UIView *dateView;//时间view
@property (nonatomic,strong)UIView *confirmView;//确定view

@property (nonatomic,strong) NSString *dutyType;//职责 分别为1.2.3.4
@property (nonatomic,strong) NSString *beginStr;//开始时间
@property (nonatomic,strong) NSString *endStr;//结束时间
@property (nonatomic,strong) NSString *dealState;//状态选择
@property (nonatomic,strong) NSString *beginSelectStr;//开始时间
@property (nonatomic,strong) NSString *endSelectStr;//结束时间
@property (nonatomic,strong)NSMutableArray *statsArr;//状态的数组
@property (nonatomic,strong)NSMutableArray *dutyArr;//职责的数组
@property (nonatomic,strong)NSMutableArray *dateArr;//时间的数组
@end

@implementation MyJobListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationTitle:self.navaTitle];
    [self setLeftBackNavigation];
    [self setRightBackNavigation];
    [self serverDateRequest];
    [self creatView];

    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    _pageNum=@"0";
    [self getDutyFlowListRequestWithState:nil];//列表请求
}

#pragma mark -creatView

- (void)creatView{
    _buttonArr=[NSMutableArray new];
    self.jobListModel=[[MyJobListModel alloc]initWithResponse:nil];
    //searchView背景
    UIView *searchView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 80)];
    [self.view addSubview:searchView];
    
    _searchTextField=[[UITextField alloc]initWithFrame:CGRectMake(10, 5, IPHONE_WIDTH-20, 30)];        //_spendTextField.color=COLOR_BACKGROUND_GRAY;
    _searchTextField.textAlignment=NSTextAlignmentLeft;
    _searchTextField.delegate=self;
    _searchTextField.font=FONT_14;
    _searchTextField.placeholder=@"请输入您要搜索的内容";
    _searchTextField.backgroundColor=COLOR_BACKGROUND_GRAY;
    //_searchTextField.keyboardType=UIKeyboardTypeNumberPad;
    _searchTextField.tag=101;
    [searchView addSubview:_searchTextField];
    
    //放大镜
    UIButton *searchBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    searchBtn.frame=CGRectMake(IPHONE_WIDTH-20-20, 0, 15, 40);
    searchBtn.tag=160;
    [searchBtn setImage:[UIImage imageNamed:@"icon_3_n@2x"] forState:UIControlStateNormal];
    [searchBtn addTarget:self action:@selector(searchClick) forControlEvents:UIControlEventTouchUpInside];
    [searchView addSubview:searchBtn];
    //分割线
    UILabel *line1=[[UILabel alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, 1)];
    line1.backgroundColor=BACKCOLOR_GRAY;
    [searchView addSubview:line1];
    
    //设置检索按钮
    NSArray *titleArr=@[@"筛选",@"职责",@"状态",@"时间"];
    
    for (int i=0; i<titleArr.count; i++) {
        UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(IPHONE_WIDTH/titleArr.count*i, 40, IPHONE_WIDTH/titleArr.count, 40)];
        button.tag=100+i;
        [button setTitle:titleArr[i] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"jiantou_down@2x"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"jiantou_up@2x"] forState:UIControlStateSelected];
        //谁知图片和文字的位置
        button.imageEdgeInsets=UIEdgeInsetsMake(10, button.width-30, 10, 10);
        button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 30);
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setTitleColor:COLOR_SKYBLUE forState:UIControlStateSelected];
        //button.backgroundColor=[UIColor redColor];
        button.titleLabel.font=FONT_14;
        //        [button setTitleColor:COLOR_MIDBLUE forState:UIControlStateSelected];
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [searchView addSubview:button];
        [_buttonArr addObject:button];
        
        if (i<titleArr.count-1) {
            UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(IPHONE_WIDTH/titleArr.count*(i+1), 50, 1, 20)];
            line.backgroundColor=BACKCOLOR_GRAY;
            [searchView addSubview:line];
        }
    }
    
    //分割线
    UILabel *line2=[[UILabel alloc]initWithFrame:CGRectMake(0, 79, IPHONE_WIDTH, 1)];
    line2.backgroundColor=BACKCOLOR_GRAY;
    [searchView addSubview:line2];
    
    //创建列表
    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, searchView.y+searchView.height, IPHONE_WIDTH, IPHONE_HEIGHT-(searchView.y+searchView.height)-64) style:UITableViewStylePlain];
    //_myTableView.backgroundColor=[UIColor redColor];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.tag=110;
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tableView.showsVerticalScrollIndicator=NO;
    _tableView.showsHorizontalScrollIndicator=NO;
    //_tableView.bounces=NO;
    [self addTableViewUpdateRefresh:_tableView BindingIdentity:@""];
//    [self addTableViewLoadMoreData:_tableView BindingIdentity:@""];
    [self.view addSubview:_tableView];
    
    //创建筛选buttonArr
    self.statsArr=[NSMutableArray new];
    self.dutyArr=[NSMutableArray new];
    self.dateArr=[NSMutableArray new];

}

#pragma mark -筛选框

- (void)creatSelectView{
    //筛选框view
    self.selectScrollView=[[UIScrollView alloc]initWithFrame:_tableView.frame];;
    self.selectScrollView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:self.selectScrollView];
    //半透明
    UIView *alphaView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, self.selectScrollView.height)];
    alphaView.alpha=0.4;
    alphaView.backgroundColor=[UIColor blackColor];
    [self.selectScrollView addSubview:alphaView];
    [self addTapGestureRecognizerWithView:alphaView];
    //状态选择
    _statsView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 86)];
    _statsView.backgroundColor=[UIColor whiteColor];
    [self.selectScrollView addSubview:_statsView];
    
    UILabel *titleLabel=[MyControl creatLabelWithFrame:CGRectMake(10, 0, IPHONE_WIDTH-20, 40) text:@"状态"];
    titleLabel.font=[UIFont boldSystemFontOfSize:16];
    [_statsView addSubview:titleLabel];
    //状态的所有按钮
    NSArray *titleArr=nil;
    if ([self.jobState isEqualToString:@"0"]) {
        titleArr=@[@"已处理",@"未处理"];
    }else{
        titleArr=@[@"已完成",@"未完成"];
    }
    CGFloat buttonWidth=(IPHONE_WIDTH-8*5)/4;
    //如果button里面有数据 则直接使用
    if (self.statsArr.count>0) {
        for (int i=0; i<self.statsArr.count; i++) {
            UIButton *signButton=self.statsArr[i];
            [_statsView addSubview:signButton];
        }
    }else{
        for (int i=0; i<titleArr.count; i++) {
            UIButton *signButton=[MyControl creatButtonWithFrame:CGRectMake(8*(i%4+1)+buttonWidth*(i%4),titleLabel.height+8*(i/4+1)+30*(i/4), buttonWidth, 30) target:self sel:@selector(statsClick:) tag:200+i image:nil title:titleArr[i]];
            //signButton.backgroundColor=COLOR_BUTTONGREEN;
            [signButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
            [signButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            signButton.layer.masksToBounds=YES;
            signButton.layer.cornerRadius=5;
            signButton.layer.borderColor=[[UIColor lightGrayColor] CGColor];
            signButton.layer.borderWidth=1;
            [_statsView addSubview:signButton];
            [_statsArr addObject:signButton];
        }
    }
    
    //职责选择
    _dutyView=[[UIView alloc]initWithFrame:CGRectMake(0, _statsView.y+_statsView.height, IPHONE_WIDTH, 124)];
    _dutyView.backgroundColor=[UIColor whiteColor];
    [self.selectScrollView addSubview:_dutyView];
    
    UILabel *dutyTitleLabel=[MyControl creatLabelWithFrame:CGRectMake(10, 0, IPHONE_WIDTH-20, 40) text:@"职责"];
    dutyTitleLabel.font=[UIFont boldSystemFontOfSize:16];
    [_dutyView addSubview:dutyTitleLabel];
    
    //职责全选按钮
    UIButton *selectAllButton=[MyControl creatButtonWithFrame:CGRectMake(8,titleLabel.height+8, buttonWidth, 30) target:self sel:@selector(dutySelectAllClick:) tag:210 image:nil title:@"全选"];
    //signButton.backgroundColor=COLOR_BUTTONGREEN;
    [selectAllButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [selectAllButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    selectAllButton.layer.masksToBounds=YES;
    selectAllButton.layer.cornerRadius=5;
    selectAllButton.layer.borderColor=[[UIColor lightGrayColor] CGColor];
    selectAllButton.layer.borderWidth=1;
    [_dutyView addSubview:selectAllButton];
    
    
    //职责的所有按钮
    NSArray *dutyTitleArr=@[@"请假",@"公出",@"加班",@"异常"];
    
    //如果button里面有数据 则直接使用
    if (self.dutyArr.count>0) {
        BOOL isSelectAll=YES;
        for (int i=0; i<_dutyArr.count; i++) {
            UIButton *signButton=_dutyArr[i];
            [_dutyView addSubview:signButton];
            if (!signButton.selected) {
                isSelectAll=NO;
            }
        }
        //如果都是选中状态 全选按钮选中
        if (isSelectAll) {
            selectAllButton.selected=YES;
            selectAllButton.backgroundColor=COLOR_SKYBLUE;
            selectAllButton.layer.borderColor=[[UIColor clearColor]CGColor];
        }
    }else{
        for (int i=0; i<dutyTitleArr.count; i++) {
            UIButton *signButton=[MyControl creatButtonWithFrame:CGRectMake(8*(i%4+1)+buttonWidth*(i%4),selectAllButton.height+selectAllButton.y+8*(i/4+1)+30*(i/4), buttonWidth, 30) target:self sel:@selector(dutyClick:) tag:220+i image:nil title:dutyTitleArr[i]];
            //signButton.backgroundColor=COLOR_BUTTONGREEN;
            [signButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
            [signButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            signButton.layer.masksToBounds=YES;
            signButton.layer.cornerRadius=5;
            signButton.layer.borderColor=[[UIColor lightGrayColor] CGColor];
            signButton.layer.borderWidth=1;
            [_dutyView addSubview:signButton];
            [_dutyArr addObject:signButton];
        }
    }
    
    //时间选择
    _dateView=[[UIView alloc]initWithFrame:CGRectMake(0, _dutyView.y+_dutyView.height, IPHONE_WIDTH, 200)];
    _dateView.backgroundColor=[UIColor whiteColor];
    [self.selectScrollView addSubview:_dateView];
    
    UILabel *dateTitleLabel=[MyControl creatLabelWithFrame:CGRectMake(10, 0, IPHONE_WIDTH-20, 40) text:@"时间"];
    dateTitleLabel.font=[UIFont boldSystemFontOfSize:16];
    [_dateView addSubview:dateTitleLabel];
    //时间的所有按钮
    NSArray *dateTitleArr=@[@"今天",@"昨天",@"前天",@"大前天",@"4天前",@"本周",@"本月",@"上月"];
    //如果button里面有数据 则直接使用
    if (self.dateArr.count>0) {
        for (int i=0; i<_dateArr.count; i++) {
            UIButton *signButton=_dateArr[i];
            [_dateView addSubview:signButton];
        }
    }else{
        for (int i=0; i<dateTitleArr.count; i++) {
            UIButton *signButton=[MyControl creatButtonWithFrame:CGRectMake(8*(i%4+1)+buttonWidth*(i%4),titleLabel.height+8*(i/4+1)+30*(i/4), buttonWidth, 30) target:self sel:@selector(dateSelectClick:) tag:230+i image:nil title:dateTitleArr[i]];
            //signButton.backgroundColor=COLOR_BUTTONGREEN;
            [signButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
            [signButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            signButton.layer.masksToBounds=YES;
            signButton.layer.cornerRadius=5;
            signButton.layer.borderColor=[[UIColor lightGrayColor] CGColor];
            signButton.layer.borderWidth=1;
            [_dateView addSubview:signButton];
            [_dateArr addObject:signButton];
        }
    }
    //自定义时间
    UILabel *customTitleLabel=[MyControl creatLabelWithFrame:CGRectMake(10, 124, IPHONE_WIDTH-20, 30) text:@"自定义时间"];
    customTitleLabel.textColor=[UIColor lightGrayColor];
    customTitleLabel.font=[UIFont systemFontOfSize:15];
    [_dateView addSubview:customTitleLabel];
    
    //选择时间的宽度
    CGFloat dateSelectBtnWidth=(IPHONE_WIDTH-88)/2;
    NSArray *dateSelectArr=@[@"选择开始时间",@"选择结束时间"];
    for (int i=0; i<dateSelectArr.count; i++) {
        UIButton *signButton=nil;
        if (i==0) {
            signButton=[MyControl creatButtonWithFrame:CGRectMake(8,8+customTitleLabel.y+customTitleLabel.height, dateSelectBtnWidth, 30) target:self sel:@selector(dateSelectButtonClick:) tag:240+i image:nil title:self.beginSelectStr?self.beginSelectStr:dateSelectArr[i]];
            //至
            UILabel *label=[MyControl creatLabelWithFrame:CGRectMake(8+dateSelectBtnWidth,8+customTitleLabel.y+customTitleLabel.height, 20, 30) text:@"至"];
            label.textColor=[UIColor lightGrayColor];
            label.textAlignment=NSTextAlignmentCenter;
            label.font=[UIFont systemFontOfSize:15];
            [_dateView addSubview:label];
        }else{
            signButton=[MyControl creatButtonWithFrame:CGRectMake(8+dateSelectBtnWidth+20,8+customTitleLabel.y+customTitleLabel.height, dateSelectBtnWidth, 30) target:self sel:@selector(dateSelectButtonClick:) tag:240+i image:nil title:self.endSelectStr?self.endSelectStr:dateSelectArr[i]];
            
            //清除按钮
            UIButton *clearButton=[MyControl creatButtonWithFrame:CGRectMake(signButton.x+signButton.width, signButton.y, 60, 30) target:self sel:@selector(clearClick) tag:250 image:nil title:@"清除"];
            [clearButton setTitleColor:COLOR_MIDBLUE forState:UIControlStateNormal];
            [_dateView addSubview:clearButton];
        }
        //signButton.backgroundColor=COLOR_BUTTONGREEN;
        [signButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [signButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        signButton.layer.masksToBounds=YES;
        signButton.layer.cornerRadius=5;
        signButton.layer.borderColor=[[UIColor lightGrayColor] CGColor];
        signButton.layer.borderWidth=1;
        [_dateView addSubview:signButton];
    }
    
    //时间选择
    _confirmView=[[UIView alloc]initWithFrame:CGRectMake(0, _dateView.y+_dateView.height, IPHONE_WIDTH, 60)];
    _confirmView.backgroundColor=[UIColor whiteColor];
    [self.selectScrollView addSubview:_confirmView];
    
    UIButton *submitButton=[MyControl creatButtonWithFrame:CGRectMake(10,10, IPHONE_WIDTH-20, 40) target:self sel:@selector(submitClick) tag:120 image:nil title:@"确定"];
    submitButton.layer.masksToBounds=YES;
    submitButton.layer.cornerRadius=5;
    [submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    submitButton.backgroundColor=COLOR_MIDBLUE;
    [_confirmView addSubview:submitButton];
}

#pragma mark -状态按钮点击
- (void)statsClick:(UIButton *)selectButton{
    [self.view endEditing:YES];
    for (int i=0; i<_statsArr.count; i++) {
        UIButton *button=_statsArr[i];
        if (selectButton.tag==button.tag) {
            button.selected=!button.selected;
            if (button.selected) {
                button.backgroundColor=COLOR_SKYBLUE;
                button.layer.borderColor=[[UIColor clearColor]CGColor];
            }else{
                button.backgroundColor=[UIColor whiteColor];
                button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
            }
            //[button setColor:BACKCOLOR_GREEN];
        }else{
            button.selected=NO;
            button.backgroundColor=[UIColor whiteColor];
            button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
            //[button setColor:BACKCOLOR_GREEN];
        }
    }
}

#pragma mark -职责按钮点击
- (void)dutyClick:(UIButton *)selectButton{
    [self.view endEditing:YES];
    BOOL isSelectAll=YES;
    UIButton *selectAllButton=(UIButton *)[_dutyView viewWithTag:210];
    for (int i=0; i<_dutyArr.count; i++) {
        UIButton *button=_dutyArr[i];
        if (selectButton.tag==button.tag) {
            button.selected=!button.selected;
            //设置button的显示方式
            if (button.selected) {
                button.backgroundColor=COLOR_SKYBLUE;
                button.layer.borderColor=[[UIColor clearColor]CGColor];
            }else{
                button.backgroundColor=[UIColor whiteColor];
                button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
            }
            //[button setColor:BACKCOLOR_GREEN];
        }
//        else{
//            button.selected=NO;
//            button.backgroundColor=[UIColor whiteColor];
//            button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
//            //[button setColor:BACKCOLOR_GREEN];
//        }
        //在点击全选后 若过用户取消其中一个选择  则需要取消全选按钮的选中状态
        if (selectAllButton.selected) {
            //如果其中一个是未选中状态
            if (!button.selected) {
                selectAllButton.selected=NO;
                selectAllButton.backgroundColor=[UIColor whiteColor];
                selectAllButton.layer.borderColor=[[UIColor lightGrayColor]CGColor];
            }
        }
        if (!button.selected) {
            isSelectAll=NO;
        }
    }
    //如果用户选择所有按钮  相当于全选
    if (isSelectAll) {
        selectAllButton.selected=YES;
        selectAllButton.backgroundColor=COLOR_SKYBLUE;
        selectAllButton.layer.borderColor=[[UIColor clearColor]CGColor];
    }
}

#pragma mark -职责全选按钮
- (void)dutySelectAllClick:(UIButton *)selectButton{
    [self.view endEditing:YES];
    selectButton.selected=!selectButton.selected;
    //如果全选则遍历所有按钮设置为已选
    if (selectButton.selected) {
        selectButton.backgroundColor=COLOR_SKYBLUE;
        selectButton.layer.borderColor=[[UIColor clearColor]CGColor];
        for (int i=0; i<_dutyArr.count; i++) {
            UIButton *button=_dutyArr[i];
            button.selected=YES;
            button.backgroundColor=COLOR_SKYBLUE;
            button.layer.borderColor=[[UIColor clearColor]CGColor];
        }
    }else{
        selectButton.backgroundColor=[UIColor whiteColor];
        selectButton.layer.borderColor=[[UIColor lightGrayColor]CGColor];
        for (int i=0; i<_dutyArr.count; i++) {
            UIButton *button=_dutyArr[i];
            button.selected=NO;
            button.backgroundColor=[UIColor whiteColor];
            button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
        }
    }
}

#pragma mark -时间按钮点击
- (void)dateSelectClick:(UIButton *)selectButton{
    [self.view endEditing:YES];
    //遍历所有按钮  设置按钮状态
    for (int i=0; i<_dateArr.count; i++) {
        UIButton *button=_dateArr[i];
        if (selectButton.tag==button.tag) {
            button.selected=!button.selected;
            //选中
            if (button.selected) {
                button.backgroundColor=COLOR_SKYBLUE;
                button.layer.borderColor=[[UIColor clearColor]CGColor];
            //取消选中
            }else{
                button.backgroundColor=[UIColor whiteColor];
                button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
            }
            //[button setColor:BACKCOLOR_GREEN];
        }else{
            button.selected=NO;
            button.backgroundColor=[UIColor whiteColor];
            button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
            //[button setColor:BACKCOLOR_GREEN];
        }
    }
    //重置按钮为初始状态
    UIButton *startButton=(UIButton *)[_dateView viewWithTag:240];
    UIButton *endButton=(UIButton *)[_dateView viewWithTag:241];
    [startButton setTitle:@"选择开始时间" forState:UIControlStateNormal];
    [endButton setTitle:@"选择结束时间" forState:UIControlStateNormal];
    [startButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [endButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
}

#pragma mark -时间选择按钮点击
- (void)dateSelectButtonClick:(UIButton *)button{
    [self.view endEditing:YES];
    //日期选择页面
    DateSelectView *datePickerView=[[DateSelectView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT)nowDateStr:nil];
    //            __weak UITableView *myTableView=_tableView;
    __weak MyJobListViewController *mySelf=self;
    //选择日期后的回调函数
    datePickerView.sureBlock=^(NSString *timeStr){
//            if (button.tag==250) {
//                [button setTitle:[timeStr copy] forState:UIControlStateNormal];
//            }else{
//                [button setTitle:[timeStr copy] forState:UIControlStateNormal];
//            }
        [button setTitle:[timeStr copy] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        if (button.tag==240) {
            mySelf.beginSelectStr=[timeStr copy];
        }else{
            mySelf.endSelectStr=[timeStr copy];
        }
        //若用户选择了自定义时间  则需要将所有非自定义按钮重置为未选中
        for (int i=0; i<mySelf.dateArr.count; i++) {
            UIButton *button=mySelf.dateArr[i];
            button.selected=NO;
            button.backgroundColor=[UIColor whiteColor];
            button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
            //[button setColor:BACKCOLOR_GREEN];
        }
    };
    [[[UIApplication sharedApplication].delegate window] addSubview:datePickerView];
}

#pragma mark - 清除按钮点击
- (void)clearClick{
    [self.view endEditing:YES];
    //重置按钮为初始状态
    UIButton *startButton=(UIButton *)[_dateView viewWithTag:240];
    UIButton *endButton=(UIButton *)[_dateView viewWithTag:241];
    [startButton setTitle:@"选择开始时间" forState:UIControlStateNormal];
    [endButton setTitle:@"选择结束时间" forState:UIControlStateNormal];
    [startButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [endButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
}

#pragma mark -确定按钮点击
- (void)submitClick{
    [self.view endEditing:YES];
    NSString *dealState=@"";
    NSString *dutyType=@"";
    NSString *beginStr=@"";
    NSString *endStr=@"";
    //遍历所有状态按钮 获取用户所选择的筛选条件
    for (UIButton *button in self.statsArr) {
        if (button.selected) {
            if ([self.statsArr indexOfObject:button]==1) {
                dealState=@"0";
            }else{
                dealState=@"1";
            }
            break;
        }
    }
    //遍历所有职责按钮 获取用户所选择的筛选条件
    NSMutableArray *indexArr=[NSMutableArray new];
    for (UIButton *button in self.dutyArr) {
        if (button.selected) {
            //选中的button 房到数组里面
            [indexArr addObject:[NSNumber numberWithInteger:[self.dutyArr indexOfObject:button]+1]];
            //拼接
            dutyType=[indexArr componentsJoinedByString:@","];
        }
    }
     //遍历所有时间按钮 获取用户所选择的筛选条件
    for (int i=0; i<self.dateArr.count; i++) {
        UIButton *button=self.dateArr[i];
        if (button.selected) {
            switch (i) {
                //今天
                case 0:
                {
                    beginStr=[LZXHelper getEndDateStrWithDays:0 isBefore:NO];
                    endStr=[LZXHelper getEndDateStrWithDays:0 isBefore:NO];
                }
                    break;
                //昨天
                case 1:
                {
                    beginStr=[LZXHelper getEndDateStrWithDays:1 isBefore:YES];
                    endStr=[LZXHelper getEndDateStrWithDays:0 isBefore:NO];
                }
                    break;
                //前天
                case 2:
                {
                    beginStr=[LZXHelper getEndDateStrWithDays:2 isBefore:YES];
                    endStr=[LZXHelper getEndDateStrWithDays:0 isBefore:NO];
                }
                    break;
                //大前天
                case 3:
                {
                    beginStr=[LZXHelper getEndDateStrWithDays:3 isBefore:YES];
                    endStr=[LZXHelper getEndDateStrWithDays:0 isBefore:NO];
                }
                    break;
                //4天前
                case 4:
                {
                    beginStr=[LZXHelper getEndDateStrWithDays:4 isBefore:YES];
                    endStr=[LZXHelper getEndDateStrWithDays:0 isBefore:NO];
                }
                    break;
                //本周
                case 5:
                {
                    beginStr=[LZXHelper getFirstWeekTime];
                    endStr=[LZXHelper getLastWeekTime];
                }
                    break;
                //本月
                case 6:
                {
                    beginStr=[LZXHelper getFirstDayInMonth];
                    endStr=[LZXHelper getLastDayInMonth];
                }
                    break;
                //上月
                case 7:
                {
                    beginStr=[LZXHelper getFirstDayInLastMonth];
                    endStr=[LZXHelper getLastDayInLastMonth];
                }
                    break;
                default:
                    break;
            }
            break;
        }
    }
    
    UIButton *startButton=(UIButton *)[_dateView viewWithTag:240];
    UIButton *endButton=(UIButton *)[_dateView viewWithTag:241];
    //先判断有没有开始时间或者结束时间
    if ((![startButton.titleLabel.text isEqualToString:@"选择开始时间"])||(![endButton.titleLabel.text isEqualToString:@"选择结束时间"])) {
        //再判断开始时间和结束时间是不是都已选择
        if ((![startButton.titleLabel.text isEqualToString:@"选择开始时间"])&&(![endButton.titleLabel.text isEqualToString:@"选择结束时间"])) {
            //再比较开始时间和结束时间
            if (![self compareOneTime:startButton.titleLabel.text withAnotherTime:endButton.titleLabel.text]) {
                [LZXHelper postMessageWithText:@"请检查您的开始时间或结束时间!" View:self.view];
                return;
            }
            beginStr=startButton.titleLabel.text;
            endStr=endButton.titleLabel.text;
        }else{
            [LZXHelper postMessageWithText:@"请检查您的开始时间或结束时间!" View:self.view];
            return;
        }
    }
    
    self.dealState=dealState;
    self.beginStr=beginStr;
    self.endStr=endStr;
    self.dutyType=dutyType;
    //移除筛选狂
    [self removeSelectScrollViewFromSuperView];
    //发送请求
    [self getDutyFlowListRequestWithState:@"0"];
}

#pragma mark -两个时间的比较
- (BOOL)compareOneTime:(NSString *)beginStr withAnotherTime:(NSString *)endStr
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    //    NSString *oneDayStr = [dateFormatter stringFromDate:oneDay];
    //    NSString *anotherDayStr = [dateFormatter stringFromDate:anotherDay];
    NSDate *dateA = [dateFormatter dateFromString:beginStr];
    NSDate *dateB = [dateFormatter dateFromString:endStr];
    NSComparisonResult resultB = [dateA compare:dateB];
    //NSOrderedAscending 大于
    //NSOrderedDescending 小于
    if (resultB==NSOrderedAscending) {
        //前者大
        return YES;
    }else{
        return NO;
    }
}


#pragma mark -搜索事件
- (void)searchClick{
    [self.view endEditing:YES];
    if (_searchTextField.text.length>0) {
        [self getDutyFlowListRequestWithState:@"0"];
    }
}

#pragma mark -检索按钮点击

- (void)buttonClick:(UIButton *)button{
    [self.view endEditing:YES];
    if (button.tag==102) {
        
    }else if (button.tag==103){
        //[self macAddressRequest];
    }
    [self changeButton:button];
    
}

- (void)changeButton:(UIButton *)selectButton{
    //if (!button.selected) {
    for (int i=0; i<_buttonArr.count; i++) {
        UIButton *button=_buttonArr[i];
        if (selectButton.tag==button.tag) {
            button.selected=!button.selected;
            //根据开关状态 是否打开选择页面
            if (button.selected) {
                if (!self.selectScrollView) {
                    [self creatSelectView];
                }
                [self refreshSelectViewWithSelectNum:selectButton.tag-100];
            }else{
                [self removeSelectScrollViewFromSuperView];
            }
            //[button setColor:BACKCOLOR_GREEN];
        }else{
            button.selected=NO;
            //[button setColor:BACKCOLOR_GREEN];
        }
    }
    
}

#pragma mark - 折叠式cell点击
- (void)signButtonClick:(UIButton *)button{
    //点击之后刷新列表
    //MyJobListModel *selectModel=self.jobListModel.dataArr[button.tag-1000];
    for (int i=0; i<self.jobListModel.dataArr.count; i++) {
        MyJobListModel *model=self.jobListModel.dataArr[i];
        if (i==button.tag-1000) {
            model.isOpen=!model.isOpen;
        }else{
            model.isOpen=NO;
        }
    }
    [_tableView reloadData];
//    [_tableView reloadSections:[[NSIndexSet alloc]initWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
//    [_tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:button.tag-1000 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
}

#pragma mark -设置筛选页面

- (void)refreshSelectViewWithSelectNum:(NSInteger )selectNum{
    //筛选
    //重新设置筛选页面布局
    if (selectNum==0) {
        _statsView.height=86;
        _dutyView.height=124;
        _dateView.height=200;
        _statsView.hidden=NO;
        _dutyView.hidden=NO;
        _dateView.hidden=NO;
    //职责
    }else if (selectNum==1){
        _statsView.height=0;
        _dutyView.height=124;
        _dateView.height=0;
        _statsView.hidden=YES;
        _dutyView.hidden=NO;
        _dateView.hidden=YES;
    //状态
    }else if (selectNum==2){
        _statsView.height=86;
        _dutyView.height=0;
        _dateView.height=0;
        _statsView.hidden=NO;
        _dutyView.hidden=YES;
        _dateView.hidden=YES;
    //时间
    }else{
        _statsView.height=0;
        _dutyView.height=0;
        _dateView.height=200;
        _statsView.hidden=YES;
        _dutyView.hidden=YES;
        _dateView.hidden=NO;
    }
    _dutyView.y=_statsView.y+_statsView.height;
    _dateView.y=_dutyView.y+_dutyView.height;
    _confirmView.y=_dateView.y+_dateView.height;
    self.selectScrollView.contentSize=CGSizeMake(0, _confirmView.y+_confirmView.height);
}

#pragma mark -手势的响应事件
- (void)tapGestureClick{
    //点击半透明框  取消筛选框
    [self.view endEditing:YES];
    [self removeSelectScrollViewFromSuperView];
//    for (int i=0; i<_buttonArr.count; i++) {
//        UIButton *button=_buttonArr[i];
//        button.selected=NO;
////        button.backgroundColor=[UIColor whiteColor];
////        button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
//    }
}

#pragma mark -移除筛选框
- (void)removeSelectScrollViewFromSuperView{
    if (self.selectScrollView) {
        [self.selectScrollView removeFromSuperview];
        self.selectScrollView=nil;
    }
    //重置button状态
    for (int i=0; i<_buttonArr.count; i++) {
        UIButton *button=_buttonArr[i];
        button.selected=NO;
        //        button.backgroundColor=[UIColor whiteColor];
        //        button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
    }
}


#pragma mark - TableViewDelagate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.jobListModel.dataArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellID=@"MyJobListTableViewCell";
    MyJobListTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell=[[MyJobListTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        [cell.signButton addTarget:self action:@selector(signButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    MyJobListModel *model=self.jobListModel.dataArr[indexPath.row];
    cell.signButton.selected=model.isOpen;
    cell.signButton.tag=1000+indexPath.row;
    //设置statusLabel的文字
    cell.statusLabel.text=[self getStatusLabelTextWithBusinessCode:model.businessCode isOwn:model.isOwn isOperate:model.isOperate state:model.dealState];
    [self setMyJobCellWithModel:model cell:cell];
    return cell;
 }

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    MyJobListModel *model=self.jobListModel.dataArr[indexPath.row];
    if (model.isOpen) {
        return 76+61;
    }
    return 76;
}
////pragma mark -添加一条分割线
//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
//    UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 1)];
//    line.backgroundColor=BACKCOLOR_GRAY;
//    return line;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
//    return 1;
//}

//开启编辑模式
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([_jobState isEqualToString:@"1"]) {
        MyJobListModel *model=_jobListModel.dataArr[indexPath.row];
        BOOL isCanDelete1=[self compareOneTime:self.serviceTime withAnotherTime:model.content5];
        BOOL isCanDelete2=[self compareOneTime:self.serviceTime withAnotherTime:model.content6];
        //这块是根据安卓的逻辑写的  具体可询问安卓开发人员
        if ([[self getVacateTypeWithBusinessCode:model.businessCode sex:model.empSex] isEqualToString:@"加班"]) {
            if ([model.dealState isEqualToString:@"0"]||([model.dealState isEqualToString:@"1"]&&isCanDelete1)||([model.dealState isEqualToString:@"1"]&&isCanDelete2)||[model.dealState isEqualToString:@"2"]||([model.dealState isEqualToString:@"3"]&&isCanDelete1)||([model.dealState isEqualToString:@"3"]&&isCanDelete2)) {
                return YES;
            }
        }else{
            if ([model.dealState isEqualToString:@"0"]||[model.dealState isEqualToString:@"1"]||[model.dealState isEqualToString:@"2"]||([model.dealState isEqualToString:@"3"]&&isCanDelete1)||([model.dealState isEqualToString:@"3"]&&isCanDelete2)) {
                return YES;
            }
        }
        return NO;
    }
    return NO;
}
-(NSString*)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    return @"删除";
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [LZXHelper postAlertViewControllerWithTitle:@"确认要删除吗?" message:nil cancelButtonTitle:@"否" otherButtonTitle:@"是" cancelEvent:^{
        
    } otherEvent:^{
        [self postDeleteBizRequestWithIndexPath:indexPath];
    } viewController:self];
//    // 从数据源中删除
//    [self.addWorkPersonArr removeObjectAtIndex:indexPath.row-1];
//    // 从列表中删除
//    [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

#pragma mark -填充cell

- (void)setMyJobCellWithModel:(MyJobListModel *)model cell:(MyJobListTableViewCell *)cell{
    UIColor *textColor=nil;
    //根据是否超时判断颜色
    if (model.timeout.integerValue>0) {
        textColor=[UIColor lightGrayColor];
        if (model.timeout.length>0) {
            cell.timeLabel.hidden=NO;
            cell.timeLabel.text=[NSString stringWithFormat:@"剩余:%@",[self getTimeStrWithTimeOut:model.timeout]];
        }else{
            cell.timeLabel.hidden=YES;
        }
        
    }else{
        textColor=COLOR_PINK;
        NSString *newtime=[model.timeout substringFromIndex:1];
        if (newtime.length>0) {
            cell.timeLabel.hidden=NO;
            cell.timeLabel.text=[NSString stringWithFormat:@"超时:%@",[self getTimeStrWithTimeOut:newtime]];
        }else{
            cell.timeLabel.hidden=YES;
        }
    }
    //cell.statusLabel.backgroundColor=textColor;
    //cell.nameLabel.textColor=textColor;
    cell.timeLabel.textColor=textColor;
    //设置内容
    cell.nameLabel.text=[NSString stringWithFormat:@"%@  %@",model.name?model.name:@"",[self getVacateTypeWithBusinessCode:model.businessCode sex:model.empSex]];
    //计算namelabel的宽度
    CGFloat nameLabelWidth=[LZXHelper textWidthFromTextString:cell.nameLabel.text Height:cell.nameLabel.height fontSize:13]+3;
    cell.nameLabel.width=nameLabelWidth;
    //设置请假天数的frame
    //如果返回内容则显示
    if (model.days.length>0) {

        cell.holidayLabel.frame=CGRectMake(cell.nameLabel.x+cell.nameLabel.width+5, cell.nameLabel.y, cell.timeLabel.x-(cell.nameLabel.x+cell.nameLabel.width+5), cell.nameLabel.height);
        cell.holidayLabel.text=[NSString stringWithFormat:@"%@天",model.days];
    }else{
        cell.holidayLabel.hidden=YES;
    }
    
    cell.dateTimeLabel.text=model.content1?model.content1:@"";
    cell.reasonLabel.text=model.content4?model.content4:@"";
//    //动态计算请假理由的高度
//    CGFloat reasonHeight=[LZXHelper textHeightFromTextString:cell.reasonLabel.text width:cell.reasonLabel.width fontSize:12];
//    if (reasonHeight>20) {
//        cell.reasonLabel.height=reasonHeight+3;
//    }
    [cell setScrollViewWithModel:model];
    //根据返回诗句设置空间的颜色
    [self setTextColorWithBusinessCode:model.businessCode isOwn:model.isOwn isOperate:model.isOperate state:model.dealState overTime:model.timeout cell:cell];
}

#pragma mark -设置cell的文本颜色
- (void)setTextColorWithBusinessCode:(NSString *)businessCode isOwn:(NSString *)isOwn isOperate:(NSString *)isOperate state:(NSString *)state overTime:(NSString *)overtime cell:(MyJobListTableViewCell *)cell{
    if ([state isEqualToString:@"0"]) {
        // 草稿状态
        // 已处理
        //        holder.dealStateName.setBackground(context.getResources()
        //                                           .getDrawable(R.drawable.k_shape_kuang_gray1));
        cell.statusLabel.backgroundColor=[UIColor grayColor];
        // 姓名
        //        holder.name.setTextColor(context.getResources().getColor(
        //                                                                 R.color.gray));
        cell.nameLabel.textColor=[UIColor grayColor];
        // 请假类型
        //        holder.vacateType.setTextColor(context.getResources().getColor(
        //                                                                       R.color.gray));
    } else {
        // 图标色
        if ([isOperate isEqualToString:@"0"]) {
            // 已处理
            //            holder.dealStateName.setBackground(context.getResources()
            //                                               .getDrawable(R.drawable.k_shape_kuang_gray1));
            cell.statusLabel.backgroundColor=[UIColor grayColor];
            // 姓名
            //            holder.name.setTextColor(context.getResources().getColor(
            //                                                                     R.color.gray));
            cell.nameLabel.textColor=[UIColor grayColor];
            // 请假类型
            //            holder.vacateType.setTextColor(context.getResources()
            //                                           .getColor(R.color.gray));
        } else if ([isOperate isEqualToString:@"1"]) {
            // 判断是否超时
            if (overtime.integerValue > 0) {
                // 未处理
                cell.statusLabel.backgroundColor=COLOR_SKYBLUE;
                // 姓名
                cell.nameLabel.textColor=COLOR_SKYBLUE;
                // 请假类型
//                holder.vacateType.setTextColor(context.getResources()
//                                               .getColor(R.color.blue2));
            } else {
                // 未处理
                cell.statusLabel.backgroundColor=COLOR_PINK;
                // 姓名
                cell.nameLabel.textColor=COLOR_PINK;
                // 请假类型
//                holder.vacateType.setTextColor(context.getResources()
//                                               .getColor(R.color.red));
                
            }
        }
        
    }
}

#pragma mark -审批详情
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    MyJobListModel *model=self.jobListModel.dataArr[indexPath.row];
    //切割开始时间和结束时间
    NSArray *timeArr=[model.content1 componentsSeparatedByString:@"至"];
    TaskDetailViewController *detail=[TaskDetailViewController new];
    detail.jobState=self.jobState;
    detail.businessCode=model.businessCode;
    detail.vacateBillId=model.ids;
    detail.sex=model.empSex;
    detail.isOperate=model.isOperate;
    detail.dealState=model.dealState;
    detail.isOwn=model.isOwn;
    if (timeArr.count>1) {
        detail.beginStr=timeArr[0];
        detail.endStr=timeArr[1];
    }
    [self.navigationController pushViewController:detail animated:YES];
}


#pragma mark -获取超时的时长
- (NSString *)getTimeStrWithTimeOut:(NSString *)timeout{
    NSInteger time=timeout.integerValue;

    if (time/60<24&&(time/60)>=1) {
        return [NSString stringWithFormat:@"%.1f小时",(float)time/60];
    }else if(time/60<1){
        return [NSString stringWithFormat:@"%.1f分钟",(float)time];
    }else{
        return [NSString stringWithFormat:@"%.1f天",(float)time/(60*24)];
    }
}
#pragma mark -刷新
- (void)loadUpdateRefreshWithBindingIdentity:(NSString *)BindingIdentity{
    _isRefresh=YES;
    if (self.jobListModel.dataArr.count>0) {
        MyJobListModel *model=[self.jobListModel.dataArr firstObject];
        _pageNum=model.fid;
    }
    [self getDutyFlowListRequestWithState:@"2"];
}
#pragma mark -加载更多
- (void)loadMoreDataWithBindingIdentity:(NSString *)BindingIdentity{
    _isLoadMore=YES;
    if (self.jobListModel.dataArr.count>0) {
        MyJobListModel *model=[self.jobListModel.dataArr lastObject];
        _pageNum=model.fid;
    }
    [self getDutyFlowListRequestWithState:@"1"];
}

#pragma mark -textFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    [self addTapGestureRecognizerWithView:_tableView];
    return YES;
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
    [self removeTapGestureRecognizerWithView:_tableView];
    return YES;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self.view endEditing:YES];
    if (_searchTextField.text.length>0) {
        [self getDutyFlowListRequestWithState:@"0"];
    }
    return YES;
}

#pragma mark -任务列表请求
//state 0 默认（获取默认数据）1 上拉（获取新数据）2 下拉（获取旧数据）
- (void)getDutyFlowListRequestWithState:(NSString *)state{
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *dict=@{
                         @"beginTime":self.beginStr?self.beginStr:@"",
                         @"dealState":self.dealState?self.dealState:@"",
                         @"dutyType":self.dutyType?self.dutyType:@"",
                         @"endTime":self.endStr?self.endStr:@"",
                         @"fid":_pageNum?_pageNum:@"0",
                         @"jobState":self.jobState?self.jobState:@"",
                         @"keyword":_searchTextField.text.length?_searchTextField.text:@"",
                         @"state":state?state:@"0",
                         @"strPage":@""
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getDutyFlowList soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        MyJobListModel *model=[[MyJobListModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"200"]) {
            //刷新的时候
            if (_isRefresh) {
                //将新数据插入到列表中
                if (model.dataArr.count>0) {
                    [self.jobListModel.dataArr insertObjects:model.dataArr atIndexes:[NSIndexSet indexSetWithIndex:0]];
                }
                [self endRefreshWithTableView:_tableView];
            //加载更多
            }else if (_isLoadMore){
                for (int i=0;i<model.dataArr.count ; i++) {
                    MyJobListModel *newModel=model.dataArr[i];
                    [self.jobListModel.dataArr addObject:newModel];
                }
                [self endRefreshWithTableView:_tableView];
            //第一次加载
            }else{
                self.jobListModel=model;
                if (!(self.jobListModel.dataArr.count<10)) {
                    [self addTableViewLoadMoreData:_tableView BindingIdentity:@""];
                }
            }
            if (self.jobListModel.dataArr.count==0) {
                [self addReminderViewWithFrame:_tableView.frame msg:@"当前查询条件下暂时没有信息~" backView:self.view];
            }else{
                [self removeReminderView];
            }
            [_tableView reloadData];
        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -撤销公出申请、加班申请、异常解释
- (void)postDeleteBizRequestWithIndexPath:(NSIndexPath *)indexPath{
    MyJobListModel *jobModel=_jobListModel.dataArr[indexPath.row];
    NSDictionary *dict=@{
                         @"bisNizCode":jobModel.businessCode?jobModel.businessCode:@"",
                         @"id":jobModel.ids?jobModel.ids:@""
                         };
    NSArray *selectArr=[NSArray arrayWithObject:dict];
    NSDictionary *selectDict=@{@"delList":selectArr,
                               @"isState":@"0"};
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:selectDict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postDeleteBiz soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"220"]) {
            // 从数据源中删除
            [self.jobListModel.dataArr removeObjectAtIndex:indexPath.row];
            // 从列表中删除
            [_tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
            if (self.jobListModel.dataArr.count==0) {
                [self addReminderViewWithFrame:_tableView.frame msg:@"当前查询条件下暂时没有信息~" backView:self.view];
            }else{
                [self removeReminderView];
            }
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }else if([model.code isEqualToString:@"200"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
